<template>
  <j-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="folderName" label="文件夹名称">
          <a-input placeholder="请输入文件夹名称" v-model="model.folderName" />
        </a-form-model-item>
        <br />
      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>
import { httpAction, getAction, shareIndexurl, postAction } from '@/api/manage'

export default {


  data() {
    return {
      title: '操作',
      visible: false,
      id: '',
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },

      confirmLoading: false,
      url: {
        add: '/bus/busFolder/byIdAdd',
      },
      validatorRules: {
        folderName: [{ required: true, message: '请输入文件夹名称' }],
      },


    }
  },


  methods: {
    handleCancel() {
      this.close()
      this.model = {}
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.$refs.form.clearValidate()
    },
    coypValue(value) {
      this.id = value
    },
    //提交表单
    handleOk() {
      console.log(this.id+"--")
      // 触发表单验证
      this.$refs.form.validate(valid => {
        if (valid)

          this.confirmLoading = true
          let httpurl = ''
          let params = {}


        httpurl = this.url.add
        params={
            id:this.id,
            folderName:this.model.folderName,
          }
        console.log("进来了")
          postAction(httpurl, params).then((res) => {
            if (res.success) {
              this.$message.success(res.message);
            } else {
              that.$message.warning(res.message);
            }
          }).finally(() => {
              this.confirmLoading = false
              this.visible=false;
              this.id='';
              this.model={};
              this.$emit('showTree');
              this.$emit('ok');
          })
      })
    }
  }
}
</script>

<style lang="less" scoped></style>
